package com.gongpingjialoan.view;

import android.app.Activity;
import android.app.Dialog;
import android.content.Context;
import android.os.Bundle;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.widget.Button;
import android.widget.ImageView;

import com.gongpingjialoan.R;
import com.gongpingjialoan.activity.car.FastBuyCar;
import com.gongpingjialoan.utility.DhUtil;

/**
 * Created by Administrator on 2015/11/26.
 */
public class FastBuyCarDialog extends Dialog implements View.OnClickListener {

    private ImageView cancalImageView;

    private Button see_collectButton , evalButton;

    private int padding;

    private FastBuyCar fastBuyCarActivity;

    public FastBuyCarDialog(Context context) {
        super(context, R.style.dialogs);
        fastBuyCarActivity = (FastBuyCar) context;
        padding = DhUtil.dip2px(context, 20);
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.fast_buy_diaglog);
        Window win = getWindow();
        win.getDecorView().setPadding(padding, 0, padding, 0);
        WindowManager.LayoutParams lp = win.getAttributes();
        lp.width = WindowManager.LayoutParams.MATCH_PARENT;
        lp.height = WindowManager.LayoutParams.WRAP_CONTENT;
        win.setAttributes(lp);
        cancalImageView = (ImageView) findViewById(R.id.cancle);
        see_collectButton =  (Button) findViewById(R.id.go_to_collect);
        evalButton =  (Button) findViewById(R.id.go_eval);
        cancalImageView.setOnClickListener(this);
        see_collectButton.setOnClickListener(this);
        evalButton.setOnClickListener(this);
    }

    @Override
    public void onClick(View v) {
        if(v == cancalImageView){
            dismiss();
        }

        if(v == see_collectButton){
//            Intent intent = new Intent(fastBuyCarActivity , HistoryCollectActivity.class);
//            intent.putExtra("fromType", 4);
//            intent.putExtra("from", "HistoryCollectActivity");
//            fastBuyCarActivity.startActivity(intent);
//            fastBuyCarActivity.finish();
        }

        if(v == evalButton){
            dismiss();
            fastBuyCarActivity.setResult(Activity.RESULT_OK);
            fastBuyCarActivity.finish();
        }


    }
}
